package com.ruoyi.staff.controller;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.staff.domain.Record;
import com.ruoyi.staff.mapper.WebscoketMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@CrossOrigin
@RestController
public class WsController {
    @Autowired
    private WebscoketMapper webscoketMapper;

    @PostMapping("/updateStatus")
    private AjaxResult updateStatus(@RequestBody Record record){
        long id = Long.parseLong(record.getId());
        long staffServiceId=Long.parseLong(record.getStaffServiceId());
        int updatedNum=0;
        if(record.getRole().equals("user")){
            updatedNum=webscoketMapper.updateUserServiceIsWatch(id,staffServiceId);
        }else{
            updatedNum= webscoketMapper.updateDriverServiceIsWatch(id,staffServiceId);
        }
        System.out.println("-------------------------555------个数"+updatedNum);
        return  AjaxResult.success("updatedNum"+updatedNum);
    }
}
